/*
 * Copyright (c) 2021 Zsj. All rights reserved.
 */

package com.jzz.crawlerweb.handler.config;

import org.springframework.util.AntPathMatcher;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求URL与验证码类型的映射
 */
public class CaptchaUrlMap {
    protected static final Map<String, String> map = new HashMap<>();

    private static final AntPathMatcher antPathMatcher = new AntPathMatcher();

    public static String getType(String url) {
        if (map.containsKey(url)) {
            return map.get(url);
        }

        for (String key : map.keySet()) {
            if (antPathMatcher.match(key, url)) {
                return map.get(key);
            }
        }

        return "";
    }
}
